package com.zh.elec.web.actions;

import java.util.List;

import com.zh.elec.model.Product;
import com.zh.elec.service.ProductService;
import com.zh.elec.web.actions.base.AbstractAction;

/**
 * 商品表
 * @author scy
 *
 */
public class ProductAction extends AbstractAction {

	/**
	 * 
	 */
	private static final long serialVersionUID = -3366879334034083959L;
	private ProductService productService;
	private Product product;
	private List<Product> list;
	/**
	 * 添加
	 * @return
	 */
	public String save(){
		if(product != null){
			product = (Product)productService.save(product);
			return "success";
		}
		return "add";
	}
	/**
	 * 修改
	 * @return
	 */
	public String update(){
		product = (Product)productService.update(product);
		return "success";
	}
	/**
	 * 删除
	 * @return
	 */
	public String del(){
		product = (Product)productService.del(product);
		return "success";
	}
	/**
	 * 查询
	 * @return
	 */
	public String find(){
		list = productService.findAll();
		return "success";
	}
	/**
	 * 根据name查询
	 * @return
	 */
	public String findByName(){
		String name = "";
		String value= "";
		List<Product> list = productService.findByName(name, value);
		System.out.println(list.size());
		return "success";
	}
	
	public Product getProduct() {
		return product;
	}
	public void setProduct(Product product) {
		this.product = product;
	}
	public void setProductService(ProductService productService) {
		this.productService = productService;
	}
	public List<Product> getList() {
		return list;
	}
	public void setList(List<Product> list) {
		this.list = list;
	}
}
